<h1 class="page-header">
    <small>新增Banner</small>
</h1>
<hr/>
<div class="panel panel-inverse" data-sortable-id="form-stuff-1">
    <div class="panel-heading">
        <h4 class="panel-title">Banner信息</h4>
    </div>
    <div class="panel-body">
        <form class="form-horizontal" id="bannerForm" name="bannerForm" action="" method="post">
            <div class="form-group">
                <label class="col-md-3 control-label">标题：</label>
                <div class="col-md-9">
                    <input type="text" id="title" class="form-control" name="title" placeholder="标题，长度2-100" rangelength="2, 100" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">图片：</label>
                <div class="col-md-9">
                    <img name="image1" class="m-r-20 m-b-10" id="image1" src="<@mh.static/>/default-coupon.jpg" style="border:1px solid #ccc;border-radius:5px;width: 180px;height: 100px;">
                    <input type="file" name="picture1" id="picture1" style="display: inline-block" onchange="ajaxFileUpload(1,'${rc.contextPath}/backend');">
                    <div style="color:#cccccc;margin-bottom: 10px;">（格式：jpeg/jpg/png，大小：540x300）</div>
                    <input type="text" type="hidden" placeholder="图片路径" class="form-control" name="image" id="filePath1" value="" onchange="changeImagePath('<@mh.static/>', '1')">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">链接：</label>
                <div class="col-md-9">
                    <input type="text" id="url" class="form-control" name="url" placeholder="链接，长度2-100" rangelength="2, 100" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">描述：</label>
                <div class="col-md-9">
                    <textarea rows="5" class="form-control" id="description" name="description" maxlength="1000" placeholder="描述信息"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label"></label>
                <div class="col-md-9">
                    <button type="button" id="submitButton" class="btn btn-sm btn-success">提交</button>
                    <button type="button" class="btn btn-sm btn-danger"
                            onclick="getData('${rc.contextPath}/backend/banner/queryList','displayArea')">返回
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="application/javascript">
    $(function () {
        $('#submitButton').click(function () {
            if ($("#title").val() != null || $("#title").val() != "") {
                $('#bannerForm').submit();
            }
        });

        $('#bannerForm').validate({
            rules: {},
            messages: {},
            errorPlacement: function (error, element) {
                error.appendTo(element.parent());
            },
            submitHandler: function () {
                postDataByFormParams('${rc.contextPath}/backend/banner/create', 'displayArea', 'bannerForm');
            }
        })
    })
</script>

